<template>
  <van-cell class="comment-item">
    <!-- 头像 -->
    <van-image slot="icon" round cover :src="comment.aut_photo" />
    <!-- /头像 -->

    <div slot="title" class="title-wrap">
      <!-- 昵称 -->
      <span class="author-name">{{ comment.aut_name }}</span>
      <!-- /昵称 -->

      <!-- 评论内容 -->
      <p class="author-content">{{ comment.content }}</p>
      <!-- /评论内容 -->

      <!-- 回复 -->
      <div class="reply-wrap">
        <span class="time-stamp">{{ comment.pubdate | relativeTime }}</span>
        &nbsp; &nbsp; &nbsp;
        <van-button
          v-if="!inReply"
          @click="$bus.$emit('reply-click', comment)"
          size="mini"
          round
          >{{ comment.reply_count }}回复</van-button
        >
      </div>
      <!-- /回复 -->

      <!-- 点赞 -->
      <div class="liking-wrap">
        <van-icon
          @click="$emit('onLiking', comment)"
          :color="comment.is_liking ? 'hotpink' : ''"
          :name="comment.is_liking ? 'good-job' : 'good-job-o'"
        /><span class="liking-number">{{ comment.like_count }}</span>
      </div>
      <!-- /点赞 -->
    </div>
  </van-cell>
</template>

<script>
export default {
  name: "CommentItem",
  props: ["comment", "inReply"],
};
</script>

<style scoped lang="less">
.comment-item {
  padding: 28px 0 0 0;

  .van-image {
    width: 36px;
    height: 36px;
  }

  .title-wrap {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-left: 12px;

    .author-name {
      height: 12px;
      font-size: 12px;
      line-height: 16px;
      color: #8da3c2;
    }

    .author-content {
      margin: 14px 0;
      font-size: 16px;
      color: #636363;
    }

    .reply-wrap {
      display: flex;
      align-items: center;
      height: 16px;
      line-height: 16px;
      font-size: 9px;

      .time-stamp {
        color: #414141;
      }

      .time-stamp::after {
        content: " ·";
        font-weight: 700;
      }

      .van-button {
        height: 16px;
        color: #222222;
      }
    }

    .liking-wrap {
      position: absolute;
      top: 27px;
      right: 0;
      font-size: 16px;

      .liking-number {
        font-size: 8px;
      }
    }
  }
}
</style>
